#include <bits/stdc++.h>
using namespace std;
int n, m;
int mp[505][505];
bool vis[505][505];
char fwd[] = {'D', 'L', 'R', 'U'};
int dx[] = {1, 0, 0, -1};
int dy[] = {0, -1, 1, 0};
struct tmp {
    int x;
    int y;
    int len;
    char s;
    tmp* last;
    tmp(int x, int y, int len, char s, tmp* last) : x(x), y(y), len(len), s(s), last(last) {}
    tmp() : tmp(0, 0, 0, 0, nullptr) {}
    void print() {
        cout << len << endl;
        string x;
        for (tmp* now = this; now->last; now = now->last) {
            x = string(1, now->s) + x;
        }
        cout << x << endl;
    }
};
void bfs() {
    tmp* head = new tmp(1, 1, 0, 0, nullptr);
    vis[1][1] = 0;
    queue<tmp*> q;
    q.push(head);
    while (!q.empty()) {
        tmp& now = *q.front();
        q.pop();
        if (now.x == n && now.y == m) {
            now.print();
            return;
        }
        for (int i = 0; i < 4; i++) {
            if (vis[now.x + dx[i]][now.y + dy[i]] || mp[now.x + dx[i]][now.y + dy[i]]) continue;
            vis[now.x + dx[i]][now.y + dy[i]] = 1;
            tmp* nxt = new tmp(now.x + dx[i], now.y + dy[i], now.len + 1, fwd[i], &now);
            q.push(nxt);
        }
    }
}
int main() {
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        mp[0][i] = mp[n + 1][i] = 1;
    }
    for (int i = 1; i <= n; i++) {
        mp[i][0] = mp[i][m + 1] = 1;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            scanf("%1d", &mp[i][j]);
        }
    }
    bfs();
}